//
//  CusNavButton.m
//  DSSH
//
//  Created by Fuhao on 16/3/31.
//  Copyright © 2016年 lcy. All rights reserved.
//

#import "CusNavButton.h"
#import "UIView+Ext.h"
@implementation CusNavButton


- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.titleLabel.font = [UIFont systemFontOfSize:9.0];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    if(_styleoftitle == CusNavButtonstyloftitlebo){
        self.imageView.y = 0;
        self.imageView.x = 0;
        self.titleLabel.x = self.imageView.x;
        self.titleLabel.y = CGRectGetMaxY(self.imageView.frame) + 5;
        self.titleLabel.w = self.w;
    }
    if(_styleoftitle == CusNavButtonstyloftitleup){
        
        self.titleLabel.y =5;
        self.imageView.x = self.center.x-self.imageView.frame.size.width-5;
        self.imageView.y =  CGRectGetMaxY(self.titleLabel.frame) + 5;
    }
    if(_styleoftitle == CusNavButtonstyloftitlele)
    {
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).with.offset(25);
            make.centerY.equalTo(self.mas_centerY);
            
        }];
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_right).with.offset(-15);
            make.centerY.equalTo(self.mas_centerY);
            //make.width.mas_equalTo();
        }];
    }
    if(_styleoftitle == CusNavButtonstyloftitleri)
    {
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(200);
            make.centerY.equalTo(self.mas_centerY);
        }];
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.imageView.mas_right).with.offset(20);
            make.centerY.equalTo(self.mas_centerY);
        }];
    }

    
    
    
}

@end
